﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpAlgorithm
{
    public class GetConsole
    {
        private static string consolString = "";
        public static string GetLine()
        {
            return consolString;
        }
        public static string GetString()
        {
            if (consolString == string.Empty)
            {
                consolString = Console.ReadLine();
            }
            string returnVal = string.Empty;
            string[] strList = consolString.Trim().Replace("\r\n", " ").Split(' ');
            returnVal = strList[0];
            consolString = string.Empty;
            for (int i = 1; i < strList.Length; i++)
            {
                consolString += strList[i] + " ";
            }
            return returnVal;
        }

        public static int GetInt()
        {
            if (consolString == string.Empty)
            {
                consolString = Console.ReadLine();
            }
            int returnVal = 0;
            if (!string.IsNullOrEmpty(consolString))
            {
                string[] strList = consolString.Trim().Replace("\r\n", " ").Split(' ');
                returnVal = Int32.Parse(strList[0]);
                consolString = string.Empty;
                for (int i = 1; i < strList.Length; i++)
                {
                    consolString += strList[i] + " ";
                }
            }
            return returnVal;
        }
    }
}
